import time

from OCC.Core import BOPAlgo
from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Common
from OCC.Display.SimpleGui import init_display
from OCC.Extend.DataExchange import read_step_file

cheese=read_step_file("cheese.stp")
planes=read_step_file("planes.stp")



#普通布尔运算
print("开始进行布尔运算")
start=time.time()
BRepAlgoAPI_Common(cheese,planes)
print("完成时间为",time.time()-start,"s")

#加速布尔运算
BOPAlgo.BOPAlgo_Algo_SetParallelMode(True)
print("开始进行布尔运算")
start2=time.time()
bop=BRepAlgoAPI_Common(cheese,planes)
print("完成时间为",time.time()-start2,"s")


if __name__ == '__main__':
    display,start_display,add_menu,add_function_to_menu = init_display()
    display.DisplayShape( bop.Shape(), update=True)
    start_display()
